<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">


    <!-- INTERFACE -->
    <cc:interface>
        <cc:attribute name="bill" type="com.divudi.entity.Bill" />
        <cc:attribute name="duplicate" type="java.lang.Boolean"/>
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>




        <h:outputStylesheet library="css" name="pharmacypos.css" ></h:outputStylesheet>
        <div class="fiveinchbill" >

            <div class="institutionName">
                <h:outputLabel value="#{cc.attrs.bill.department.printingName}" />
            </div>
            <div class="institutionContact" >
                <div>
                    <h:outputLabel value="#{cc.attrs.bill.department.address}"/>
                </div>
                <div >
                    <h:outputLabel value="#{cc.attrs.bill.department.telephone1} "/>
                    <h:outputLabel value="#{cc.attrs.bill.department.telephone2}"/>
                </div>
                <div >
                    <h:outputLabel value="#{cc.attrs.bill.department.fax}"/>                                                 
                </div>
            </div>

            <div class="headingBillFiveFive" style="text-align: center;font-weight: bold;">
                <h:outputLabel value="RECEIPT"   />    
                <h:outputLabel value="**Duplicate**"  rendered="#{cc.attrs.duplicate eq true}" /> 
                <h:outputLabel value="**Cancelled**"  rendered="#{cc.attrs.bill.cancelled eq true}" /> 
            </div>

            <div class="billline">
                <br/>
                <hr></hr>   
                <br/>
            </div>

            <div class="billDetailsFiveFive" >
                <table style="width: 99%!important;" >



                    <tr>
                        <td style="text-align: left;" >
                            <h:outputLabel value="Name" class="billDetailsFiveFive" ></h:outputLabel>
                        </td>
                        <td style="width: 10px;"></td>
                        <td >:</td>
                        <td style="width: 5px;"></td>
                        <td>
                            <h:outputLabel value="#{cc.attrs.bill.patient.person.nameWithTitle}" class="billDetailsFiveFive" >
                            </h:outputLabel>

                        </td>
                        <td style="width: 50px;"></td>
                        <td>
                            <h:outputLabel value="Bill Date" class="billDetailsFiveFive" ></h:outputLabel>
                        </td>
                        <td>
                            <h:outputLabel value=":" class="billDetailsFiveFive" ></h:outputLabel>
                        </td>

                        <td>
                            <h:outputLabel value="#{cc.attrs.bill.createdAt}" class="billDetailsFiveFive">
                                <f:convertDateTime pattern="dd/MMM/yyyy" ></f:convertDateTime>
                            </h:outputLabel>
                        </td>

                    </tr>

                    <tr>
                        <td style="text-align: left;" >
                            <h:outputLabel value="Age" class="billDetailsFiveFive" ></h:outputLabel>
                        </td>
                        <td style="width: 10px;"></td>
                        <td >:</td>
                        <td style="width: 5px;"></td>
                        <td>
                            <h:outputLabel value="#{cc.attrs.bill.patient.age}" class="billDetailsFiveFive" >
                            </h:outputLabel>

                        </td>
                        <td style="width: 50px;"></td>
                        <td>
                            <h:outputLabel value="Bill Time" class="billDetailsFiveFive" ></h:outputLabel>
                        </td>
                        <td>
                            <h:outputLabel value=":" class="billDetailsFiveFive" ></h:outputLabel>
                        </td>

                        <td>
                            <h:outputLabel value="#{cc.attrs.bill.createdAt}" class="billDetailsFiveFive">
                                <f:convertDateTime pattern="hh:mm a" ></f:convertDateTime>
                            </h:outputLabel>
                        </td>

                    </tr>


                    <tr>
                        <td style="text-align: left;" >
                            <h:outputLabel value="Gender" class="billDetailsFiveFive" ></h:outputLabel>
                        </td>
                        <td style="width: 10px;"></td>
                        <td >:</td>
                        <td style="width: 5px;"></td>
                        <td>
                            <h:outputLabel value="#{cc.attrs.bill.patient.person.sex}" class="billDetailsFiveFive" >
                            </h:outputLabel>

                        </td>
                        <td style="width: 50px;"></td>
                        <td>
                            <h:outputLabel value="Bill No" class="billDetailsFiveFive" ></h:outputLabel>
                        </td>
                        <td>
                            <h:outputLabel value=":" class="billDetailsFiveFive" ></h:outputLabel>
                        </td>

                        <td>
                            <h:outputLabel value="#{cc.attrs.bill.insId}" class="billDetailsFiveFive">
                            </h:outputLabel>
                        </td>

                    </tr>


                    <tr>
                        <td style="text-align: left;" >
                            <h:outputLabel value="Phone" class="billDetailsFiveFive" ></h:outputLabel>
                        </td>
                        <td style="width: 10px;"></td>
                        <td >:</td>
                        <td style="width: 5px;"></td>
                        <td>
                            <h:outputLabel value="#{cc.attrs.bill.patient.person.phone}" class="billDetailsFiveFive" >
                            </h:outputLabel>

                        </td>
                        <td style="width: 50px;"></td>
                        <td>
                            <h:outputLabel value="Payment" class="billDetailsFiveFive" ></h:outputLabel>
                        </td>
                        <td>
                            <h:outputLabel value=":" class="billDetailsFiveFive" ></h:outputLabel>
                        </td>

                        <td>
                            <h:outputLabel value="#{cc.attrs.bill.paymentMethod}" class="billDetailsFiveFive">
                            </h:outputLabel>
                        </td>

                    </tr>

                    <tr>
                        <td style="text-align: left;" >
                            <h:outputLabel value="Patient ID" class="billDetailsFiveFive" ></h:outputLabel>
                        </td>
                        <td style="width: 10px;"></td>
                        <td >:</td>
                        <td style="width: 5px;"></td>
                        <td>
                            <h:outputLabel value="#{cc.attrs.bill.patient.phn}" class="billDetailsFiveFive" >
                            </h:outputLabel>

                        </td>
                        <td style="width: 50px;"></td>
                        <td>
                            <h:outputLabel value="Referred By" class="billDetailsFiveFive" ></h:outputLabel>
                        </td>
                        <td>
                            <h:outputLabel value=":" class="billDetailsFiveFive" ></h:outputLabel>
                        </td>

                        <td>
                            <h:outputLabel value="#{cc.attrs.bill.referredBy.person.nameWithTitle}" class="billDetailsFiveFive">
                            </h:outputLabel>
                        </td>

                    </tr>

                </table>
            </div>


            <h:panelGroup  rendered="#{sessionController.loggedPreference.printBarcodeInOpdBill or true}" >
                <div class="billline">
                    <div style="width: 100%;text-align: center;font-size: 10px;">
                        <p:barcode value="#{cc.attrs.bill.idStr}" type="code39" cache="false" 
                                   />
                    </div>
                </div>
            </h:panelGroup>

            <div class="itemHeadingsFiveFive" >

                <table width="100%" style="width: 100%;" >
                    <tr>
                        <td colspan="2" style="text-align: center;" class="billline">
                            <hr/>
                        </td>
                    </tr>
                    <tr>
                        <td style="width:55%!important;">
                            <h:outputLabel value="ITEM" styleClass="itemHeadingsFiveFive" ></h:outputLabel>
                        </td>
                        <td  style="width:10%!important;text-align: right; padding-right: 30px!important">
                            <h:outputLabel value="VALUE"  styleClass="itemHeadingsFiveFive" ></h:outputLabel>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" style="text-align: center;" class="billline">
                            <hr/>
                        </td>
                    </tr>

                    <h:panelGroup rendered="#{cc.attrs.bill.margin > 0? 'false':'true'}">
                        <ui:repeat value="#{cc.attrs.bill.billItems}" var="bip"   >
                            <tr>
                                <td  style="overflow: visible;">
                                    <h:outputLabel class="itemsBlockRightFiveFive" value="#{bip.searialNo+1} - #{bip.item.name}"  style="text-transform: capitalize!important;"  >
                                    </h:outputLabel>
                                </td>
                                <td style="text-align: right;" >
                                    <h:outputLabel class="itemsBlockRightFiveFive"   value="#{bip.grossValue}"    >
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </td>
                            </tr>

                        </ui:repeat>
                    </h:panelGroup>

                    <h:panelGroup rendered="#{cc.attrs.bill.margin ne 0.0}">
                        <ui:repeat value="#{cc.attrs.bill.billItems}" var="bip"   >
                            <tr>
                                <td  style="overflow: visible;">
                                    <h:outputLabel class="itemsBlockRightFiveFive" value="#{bip.searialNo+1} - #{bip.item.name}"  style="text-transform: capitalize!important;"  >
                                    </h:outputLabel>
                                </td>
                                <td>
                                    <h:outputLabel class="itemsBlockRightFiveFive"    value="#{bip.qty}"     style="text-align: right;" >
                                        <f:convertNumber integerOnly="true" />
                                    </h:outputLabel>
                                </td>
                                <td    style="text-align: right;" >
                                    <h:outputLabel class="itemsBlockRightFiveFive"    value="#{bip.rate}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </td>

                                <td style="text-align: right;" >
                                    <h:outputLabel class="itemsBlockRightFiveFive"   value="#{bip.grossValue}"    >
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </td>

                            </tr>
                        </ui:repeat>
                    </h:panelGroup>




                </table>


            </div>


            <div class="billline">
                <br/>
                <hr/>
                <br/>

            </div>



            <div  >

                <table style="width: 100%;">

                    <h:panelGroup rendered="#{cc.attrs.bill.margin > 0? 'false':'true'}">
                        <tr>
                            <td class="totalsBlock" style="text-align: left; width: 60%;">
                                <h:outputLabel value="Total" />
                            </td>
                            <td  class="totalsBlock" style="text-align: right!important; width: 40%; padding-right: 30px;">
                                <h:outputLabel value="#{cc.attrs.bill.total}" >
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>
                            </td>
                        </tr>
                    </h:panelGroup>

                    <h:panelGroup rendered="#{cc.attrs.bill.margin ne 0.0}">
                        <tr>
                            <td class="totalsBlock" style="text-align: left; width: 60%;">
                                <h:outputLabel value="Total" />
                            </td>
                            <td  class="totalsBlock" style="text-align: right!important; width: 40%; padding-right: 30px;">
                                <h:outputLabel value="#{cc.attrs.bill.netTotal}" >
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>
                            </td>
                        </tr>
                    </h:panelGroup>

                    <h:panelGroup rendered="#{cc.attrs.bill.discount ne 0.0}">
                        <tr>
                            <td  class="totalsBlock" style="text-align: left;">
                                <h:outputLabel  rendered="#{cc.attrs.bill.discount ne 0.0}" value="Discount " style="font-weight: bolder!important;"/>
                            </td>
                            <td  class="totalsBlock" style="text-align: right!important; ; padding-right: 30px;">
                                <h:outputLabel rendered="#{cc.attrs.bill.discount ne 0.0}"   value="#{-cc.attrs.bill.discount}" style="font-weight: bolder!important;" >
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>
                            </td>
                        </tr>
                    </h:panelGroup>

                    <tr>
                        <td  class="totalsBlock" style="text-align: left;">
                            <h:outputLabel  rendered="#{cc.attrs.bill.discount ne 0.0}"    value="Net Total" />
                        </td>
                        <td  class="totalsBlock" style="text-align: right!important;font-weight: bold; ; padding-right: 30px; ">
                            <h:outputLabel  rendered="#{cc.attrs.bill.discount ne 0.0}"    value="#{cc.attrs.bill.netTotal}">
                                <f:convertNumber pattern="#,##0.00" />
                            </h:outputLabel>
                        </td>
                    </tr>

                    <tr>
                        <td  class="totalsBlock" style="text-align: left;">
                            <h:outputLabel  rendered="#{cc.attrs.bill.discount ne 0.0}"    value="VAT" />
                        </td>
                        <td  class="totalsBlock" style="text-align: right!important;font-weight: bold; ; padding-right: 30px; ">
                            <h:outputLabel  rendered="#{cc.attrs.bill.discount ne 0.0}"    value="#{cc.attrs.bill.vat}">
                                <f:convertNumber pattern="#,##0.00" />
                            </h:outputLabel>
                        </td>
                    </tr>


                </table>

            </div>

            <div style="text-decoration: overline; margin-top: 20px;">
                <h:outputLabel value="Cashier : #{cc.attrs.bill.creater.webUserPerson.name}"/>
            </div>

            <div class="footer" style="text-align: center;">
                <br/>
                <h:outputLabel value="#{sessionController.userPreference.pharmacyBillFooter}"/>
                <br/>
            </div>



        </div>
    </cc:implementation>
</html>